// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   taskDetails_register_ok.java

package security.config.task;

import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class taskDetails_register_ok extends HttpServlet
{

	ServletContext application;
	HttpSession session;

	public taskDetails_register_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		ServletContext dbApplication = dbSession.getServletContext();
		nseer_db_backup1 security_db = new nseer_db_backup1(dbApplication);
		try
		{
			if (security_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String cols_number = request.getParameter("cols_number");
				int n = 0;
				for (int j = 1; j <= Integer.parseInt(cols_number); j++)
				{
					String checkbox_name = (new StringBuilder("col")).append(j).toString();
					String cols[] = request.getParameterValues(checkbox_name);
					if (cols != null)
						n++;
				}

				if (n == 0)
				{
					response.sendRedirect("security/config/task/taskDetails_register_ok_a.jsp");
				} else
				{
					String sql2 = "delete from security_task";
					security_db.executeUpdate(sql2);
					sql2 = "update document_second set task_tag='0'";
					security_db.executeUpdate(sql2);
					for (int j = 1; j <= Integer.parseInt(cols_number); j++)
					{
						String checkbox_name = (new StringBuilder("col")).append(j).toString();
						String cols[] = request.getParameterValues(checkbox_name);
						if (cols != null)
						{
							for (int i = 0; i < cols.length; i++)
							{
								String sql = (new StringBuilder("select * from document_second where id='")).append(cols[i]).append("'").toString();
								ResultSet rs = security_db.executeQuery(sql);
								if (rs.next())
								{
									String name = (new StringBuilder(String.valueOf(rs.getString("main_kind_ID")))).append("--").append(rs.getString("first_kind_ID")).append("--").append(rs.getString("second_kind_ID")).toString();
									String url = (new StringBuilder("../../")).append(rs.getString("main_kind_name")).append("/").append(rs.getString("first_kind_name")).append("/").append(rs.getString("head_file")).toString();
									String sql1 = (new StringBuilder("insert into security_task(name,url) values('")).append(name).append("','").append(url).append("')").toString();
									security_db.executeUpdate(sql1);
									String sql3 = (new StringBuilder("update document_second set task_tag='1' where id='")).append(cols[i]).append("'").toString();
									security_db.executeUpdate(sql3);
								}
							}

						}
					}

					response.sendRedirect("security/config/task/taskDetails_register_ok_b.jsp");
				}
				security_db.commit();
				security_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
